package com.springboot.myspringbootframework.web.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAspectHandler {

    @Pointcut("@annotation(com.springboot.myspringbootframework.web.aspect.LogAspect)")
    public void weblogic(){}

    @Around("weblogic()")
    public Object aroundLogAspect(ProceedingJoinPoint point) throws Throwable {
        long start = System.currentTimeMillis();
        Object proceed = point.proceed();
        long end = System.currentTimeMillis();
        System.out.println("方法运行时间："+(end - start )+"ms");
        return proceed;
    }
}
